package com.xie.smfs.handler;

import com.xie.smfs.screen.ScreenOpener;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;

public class KeyInputHandler {
    public static final KeyBinding OPEN_CUSTOM_SCREEN = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.secondinventory.open",
            InputUtil.Type.KEYSYM,
            GLFW.GLFW_KEY_B,
            "category.secondinventory"
    ));

    public static void register() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (OPEN_CUSTOM_SCREEN.wasPressed()) {
                if (client.player != null) {
                    ScreenOpener.openCustomScreen(client.player);
                }
            }
        });
    }
}